import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useTeacherStore = defineStore('teacher', () => {
  const teacherInfo = ref(null)

  // 设置教师信息
  const setTeacherInfo = (info) => {
    teacherInfo.value = info
  }

  // 清除教师信息
  const clearTeacherInfo = () => {
    teacherInfo.value = null
  }

  // 获取审核状态
  const getAuditStatus = () => {
    return teacherInfo.value?.auditStatus
  }

  // 获取教师姓名
  const getTeacherName = () => {
    return teacherInfo.value?.realName || teacherInfo.value?.username
  }

  return {
    teacherInfo,
    setTeacherInfo,
    clearTeacherInfo,
    getAuditStatus,
    getTeacherName
  }
}, {
  persist: true
})
